using System;
using ViScript.Core.Argument;
using ViScript.Core.ParsedSentence;
using ViScript.Core.Utils;

namespace ViScript.Core.ParameterRules
{
    public class ClauseParameterRule : IParameterRule
    {
        private readonly ISentenceParser sentenceParser;

        public ClauseParameterRule(ISentenceParser sentenceParser)
        {
            this.sentenceParser = sentenceParser;
        }

        public IArgument Parse(Type type, IText text, ISentence sentence)
        {
            IParsedSentence parseSentence =
                sentenceParser.ParseSentence(new Sentence(sentence.FileName, sentence.LineNumber, text.ToString()));
            return new ClauseArgument(parseSentence);
        }
    }
}